package com.tvein.sanguo.action.controller.command
{
	//flash
	//pureMVC
	import flash.display.DisplayObject;
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.action.view.ActionMediator;
	import com.tvein.sanguo.action.model.SystemProxy;
	import com.tvein.sanguo.swc.action.command.Command2;
	import com.tvein.sanguo.swc.action.command.Command3;
	import com.tvein.sanguo.swc.action.command.Command4;
	import com.tvein.sanguo.swc.action.command.Command5;
	import com.tvein.sanguo.swc.action.command.Command6;
	import com.tvein.sanguo.swc.action.command.Command7;
	import com.tvein.sanguo.swc.action.command.Command8;
	import com.tvein.sanguo.swc.action.command.Command9;
	import com.tvein.sanguo.swc.action.command.Command10;
	import com.tvein.sanguo.swc.action.command.Command11;
	import com.tvein.sanguo.swc.action.command.Command12;
	import com.tvein.sanguo.swc.action.command.Command13;
	import com.tvein.sanguo.swc.action.command.Command23;
	import com.tvein.sanguo.swc.action.command.Command24;
	import com.tvein.sanguo.swc.action.command.Command34;
	import com.tvein.sanguo.swc.action.command.Command40;
	import com.tvein.sanguo.swc.action.command.Command85;
	import com.tvein.sanguo.swc.action.command.Command86;
	import com.tvein.sanguo.swc.action.command.Command89;
	import com.tvein.sanguo.swc.action.command.Command90;
	import com.tvein.sanguo.swc.action.command.Command91;
	import com.tvein.sanguo.swc.action.command.Command92;
	import com.tvein.sanguo.swc.action.command.Command93;
	import com.tvein.sanguo.swc.action.command.Command94;
	import com.tvein.sanguo.swc.action.command.Command95;
	import com.tvein.sanguo.swc.action.command.Command96;
	import com.tvein.sanguo.swc.action.command.Command97;
	import com.tvein.sanguo.swc.action.command.Command98;
//
	public class ActionCommand extends SimpleFabricationCommand implements ICommand
	{
		private var actionMediator:ActionMediator;
		private var systemData:SystemProxy;
		
		override public function execute(notification:INotification) : void
		{
			actionMediator = facade.retrieveMediator(ActionMediator.NAME) as ActionMediator;
			systemData = facade.retrieveProxy(SystemProxy.NAME) as SystemProxy;
			
			clearChild();

			var params:Object = new Object();
			
			switch (notification.getBody().Main.id)
			{
				case 2:
					var actionCommand2:Command2 = new Command2();
					actionMediator.action.addChild(actionCommand2);
					actionCommand2.name = "Command-2";
					
					params.Volume = systemData.effectVol;
					actionCommand2.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand2.console("setTargetId", params);
					
					actionCommand2.console("setData", notification.getBody().Process);
					
					actionCommand2.addEventListener("Command-2", actionMediator._handleEvents);
					break;
				case 3:
					var actionCommand3:Command3 = new Command3();
					actionMediator.action.addChild(actionCommand3);
					actionCommand3.name = "Command-3";
					
					params.Volume = systemData.effectVol;
					actionCommand3.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand3.console("setTargetId", params);
					
					actionCommand3.console("setData", notification.getBody().Process);
					
					actionCommand3.addEventListener("Command-3", actionMediator._handleEvents);
					break;
				case 4:
					var actionCommand4:Command4 = new Command4();
					actionMediator.action.addChild(actionCommand4);
					actionCommand4.name = "Command-4";
					
					params.Volume = systemData.effectVol;
					actionCommand4.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand4.console("setTargetId", params);
					
					actionCommand4.console("setData", notification.getBody().Process);
					
					actionCommand4.addEventListener("Command-4", actionMediator._handleEvents);
					break;
				case 5:
					var actionCommand5:Command5 = new Command5();
					actionMediator.action.addChild(actionCommand5);
					actionCommand5.name = "Command-5";
					
					params.Volume = systemData.effectVol;
					actionCommand5.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand5.console("setTargetId", params);
					
					actionCommand5.console("setData", notification.getBody().Process);
					
					actionCommand5.addEventListener("Command-5", actionMediator._handleEvents);
					break;
				case 6:
					var actionCommand6:Command6 = new Command6();
					actionMediator.action.addChild(actionCommand6);
					actionCommand6.name = "Command-6";
					
					params.Volume = systemData.effectVol;
					actionCommand6.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand6.console("setTargetId", params);
					
					actionCommand6.console("setData", notification.getBody().Process);
					
					actionCommand6.addEventListener("Command-6", actionMediator._handleEvents);
					break;
				case 7:
					var actionCommand7:Command7 = new Command7();
					actionMediator.action.addChild(actionCommand7);
					actionCommand7.name = "Command-7";
					
					params.Volume = systemData.effectVol;
					actionCommand7.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand7.console("setTargetId", params);
					
					actionCommand7.console("setData", notification.getBody().Process);
					
					actionCommand7.addEventListener("Command-7", actionMediator._handleEvents);
					break;
				case 8:
					var actionCommand8:Command8 = new Command8();
					actionMediator.action.addChild(actionCommand8);
					actionCommand8.name = "Command-8";
					
					params.Volume = systemData.effectVol;
					actionCommand8.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand8.console("setTargetId", params);
					
					actionCommand8.console("setData", notification.getBody().Process);
					
					actionCommand8.addEventListener("Command-8", actionMediator._handleEvents);
					break;
				case 9:
					var actionCommand9:Command9 = new Command9();
					actionMediator.action.addChild(actionCommand9);
					actionCommand9.name = "Command-9";
					
					params.Volume = systemData.effectVol;
					actionCommand9.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand9.console("setTargetId", params);
					
					actionCommand9.console("setData", notification.getBody().Process);
					
					actionCommand9.addEventListener("Command-9", actionMediator._handleEvents);
					break;
				case 10:
					var actionCommand10:Command10 = new Command10();
					actionMediator.action.addChild(actionCommand10);
					actionCommand10.name = "Command-10";
					
					params.Volume = systemData.effectVol;
					actionCommand10.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand10.console("setTargetId", params);
					
					actionCommand10.console("setData", notification.getBody().Process);
					
					actionCommand10.addEventListener("Command-10", actionMediator._handleEvents);
					break;
				case 11:
					var actionCommand11:Command11 = new Command11();
					actionMediator.action.addChild(actionCommand11);
					actionCommand11.name = "Command-11";
					
					params.Volume = systemData.effectVol;
					actionCommand11.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand11.console("setTargetId", params);
					
					actionCommand11.console("setData", notification.getBody().Process);
					
					actionCommand11.addEventListener("Command-11", actionMediator._handleEvents);
					break;
				case 12:
					var actionCommand12:Command12 = new Command12();
					actionMediator.action.addChild(actionCommand12);
					actionCommand12.name = "Command-12";
					
					params.Volume = systemData.effectVol;
					actionCommand12.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand12.console("setTargetId", params);
					
					actionCommand12.console("setData", notification.getBody().Process);
					
					actionCommand12.addEventListener("Command-12", actionMediator._handleEvents);
					break;
				case 13:
					var actionCommand13:Command13 = new Command13();
					actionMediator.action.addChild(actionCommand13);
					actionCommand13.name = "Command-13";
					
					params.Volume = systemData.effectVol;
					actionCommand13.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand13.console("setTargetId", params);
					
					actionCommand13.console("setData", notification.getBody().Process);
					
					actionCommand13.addEventListener("Command-13", actionMediator._handleEvents);
					break;
				case 23:
					var actionCommand23:Command23 = new Command23();
					actionMediator.action.addChild(actionCommand23);
					actionCommand23.name = "Command-23";
					
					params.Volume = systemData.effectVol;
					actionCommand23.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand23.console("setTargetId", params);
					
					actionCommand23.console("setData", notification.getBody().Process);
					
					actionCommand23.addEventListener("Command-23", actionMediator._handleEvents);
					break;
				case 24:
					var actionCommand24:Command24 = new Command24();
					actionMediator.action.addChild(actionCommand24);
					actionCommand24.name = "Command-24";
					
					params.Volume = systemData.effectVol;
					actionCommand24.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand24.console("setTargetId", params);
					
					actionCommand24.console("setData", notification.getBody().Process);
					
					actionCommand24.addEventListener("Command-24", actionMediator._handleEvents);
					break;
				case 34:
					var actionCommand34:Command34 = new Command34();
					actionMediator.action.addChild(actionCommand34);
					actionCommand34.name = "Command-34";
					
					params.Volume = systemData.effectVol;
					actionCommand34.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand34.console("setTargetId", params);
					
					actionCommand34.console("setData", notification.getBody().Process);
					
					actionCommand34.addEventListener("Command-34", actionMediator._handleEvents);
					break;
				case 40:
					var actionCommand40:Command40 = new Command40();
					actionMediator.action.addChild(actionCommand40);
					actionCommand40.name = "Command-40";
					
					params.Volume = systemData.effectVol;
					actionCommand40.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand40.console("setTargetId", params);
					
					actionCommand40.console("setData", notification.getBody().Process);
					
					actionCommand40.addEventListener("Command-40", actionMediator._handleEvents);
					break;
				case 85:
					var actionCommand85:Command85 = new Command85();
					actionMediator.action.addChild(actionCommand85);
					actionCommand85.name = "Command-85";
					
					params.Volume = systemData.effectVol;
					actionCommand85.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand85.console("setTargetId", params);
					
					actionCommand85.console("setData", notification.getBody().Process);
					
					actionCommand85.addEventListener("Command-85", actionMediator._handleEvents);
					break;
				case 86:
					var actionCommand86:Command86 = new Command86();
					actionMediator.action.addChild(actionCommand86);
					actionCommand86.name = "Command-86";
					
					params.Volume = systemData.effectVol;
					actionCommand86.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand86.console("setTargetId", params);
					
					actionCommand86.console("setData", notification.getBody().Process);
					
					actionCommand86.addEventListener("Command-86", actionMediator._handleEvents);
					break;
				case 89:
					var actionCommand89:Command89 = new Command89();
					actionMediator.action.addChild(actionCommand89);
					actionCommand89.name = "Command-89";
					
					params.Volume = systemData.effectVol;
					actionCommand89.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand89.console("setTargetId", params);
					
					actionCommand89.console("setData", notification.getBody().Process);
					
					actionCommand89.addEventListener("Command-89", actionMediator._handleEvents);
					break;
				case 90:
					var actionCommand90:Command90 = new Command90();
					actionMediator.action.addChild(actionCommand90);
					actionCommand90.name = "Command-90";
					
					params.Volume = systemData.effectVol;
					actionCommand90.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand90.console("setTargetId", params);
					
					actionCommand90.console("setData", notification.getBody().Process);
					
					actionCommand90.addEventListener("Command-90", actionMediator._handleEvents);
					break;
				case 91:
					var actionCommand91:Command91 = new Command91();
					actionMediator.action.addChild(actionCommand91);
					actionCommand91.name = "Command-91";
					
					params.Volume = systemData.effectVol;
					actionCommand91.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand91.console("setTargetId", params);
					
					actionCommand91.console("setData", notification.getBody().Process);
					
					actionCommand91.addEventListener("Command-91", actionMediator._handleEvents);
					break;
				case 92:
					var actionCommand92:Command92 = new Command92();
					actionMediator.action.addChild(actionCommand92);
					actionCommand92.name = "Command-92";
					
					params.Volume = systemData.effectVol;
					actionCommand92.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand92.console("setTargetId", params);
					
					actionCommand92.console("setData", notification.getBody().Process);
					
					actionCommand92.addEventListener("Command-92", actionMediator._handleEvents);
					break;
				case 93:
					var actionCommand93:Command93 = new Command93();
					actionMediator.action.addChild(actionCommand93);
					actionCommand93.name = "Command-93";
					
					params.Volume = systemData.effectVol;
					actionCommand93.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand93.console("setTargetId", params);
					
					actionCommand93.console("setData", notification.getBody().Process);
					
					actionCommand93.addEventListener("Command-93", actionMediator._handleEvents);
					break;
				case 94:
					var actionCommand94:Command94 = new Command94();
					actionMediator.action.addChild(actionCommand94);
					actionCommand94.name = "Command-94";
					
					params.Volume = systemData.effectVol;
					actionCommand94.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand94.console("setTargetId", params);
					
					actionCommand94.console("setData", notification.getBody().Process);
					
					actionCommand94.addEventListener("Command-94", actionMediator._handleEvents);
					break;
				case 95:
					var actionCommand95:Command95 = new Command95();
					actionMediator.action.addChild(actionCommand95);
					actionCommand95.name = "Command-95";
					
					params.Volume = systemData.effectVol;
					actionCommand95.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand95.console("setTargetId", params);
					
					actionCommand95.console("setData", notification.getBody().Process);
					
					actionCommand95.addEventListener("Command-95", actionMediator._handleEvents);
					break;
				case 96:
					var actionCommand96:Command96 = new Command96();
					actionMediator.action.addChild(actionCommand96);
					actionCommand96.name = "Command-96";
					
					params.Volume = systemData.effectVol;
					actionCommand96.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand96.console("setTargetId", params);
					
					actionCommand96.console("setData", notification.getBody().Process);
					
					actionCommand96.addEventListener("Command-96", actionMediator._handleEvents);
					break;
				case 97:
					var actionCommand97:Command97 = new Command97();
					actionMediator.action.addChild(actionCommand97);
					actionCommand97.name = "Command-97";
					
					params.Volume = systemData.effectVol;
					actionCommand97.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand97.console("setTargetId", params);
					
					actionCommand97.console("setData", notification.getBody().Process);
					
					actionCommand97.addEventListener("Command-97", actionMediator._handleEvents);
					break;
				case 98:
					var actionCommand98:Command98 = new Command98();
					actionMediator.action.addChild(actionCommand98);
					actionCommand98.name = "Command-98";
					
					params.Volume = systemData.effectVol;
					actionCommand98.console("setEffect", params);
					params.TargetId = notification.getBody().Main.targetId;
					actionCommand98.console("setTargetId", params);
					
					actionCommand98.console("setData", notification.getBody().Process);

					actionCommand98.addEventListener("Command-98", actionMediator._handleEvents);
					break;
			}
		}
		
		private function clearChild():void
		{
			for (var i:int = actionMediator.action.numChildren - 1; i >= 0; i--)
			{
				actionMediator.action.removeChildAt(0); 
			}
		}
	}
}